package cn.lxb.web.starter.template.autoconfigure.converter;

import cn.lxb.web.starter.template.helper.TimeHelper;
import org.springframework.core.convert.converter.Converter;

import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 转换器  LocalDate
 *
 * @author 54lxb
 * @since 2019-11-20
 */
public class LocalDateConverter implements Converter<String, LocalDate> {

    @Override
    public LocalDate convert(String source) {
        LocalDateTime time = TimeHelper.parseLocalDateTime(source);
        return time == null ? null : time.toLocalDate();
    }

}
